Skip to main content

All Questions

Tagged with
0votes
1answer
56views

is my Prim's MST implementation terse enough?

I did research because I want to learn Kruskal's and Prim's MSTs. I did research and after a solid understanding, I went to my textbook and got their libraries: https://algs4.cs.princeton.edu/code/...
William Golovlev's user avatar
5votes
2answers
13kviews

Java: Given a list of edges, build a tree and return the root

In an interview I was asked to write Java code to build a tree and return the root, given a list of edges. It was a fairly open ended question where the interviewer left all the decisions up to me. I ...
Sid's user avatar
  • 53
1vote
1answer
738views

Check directed graph is tree or not

Here is my approach. 1. Checking there is no cycle.(Using BFS) 2. All nodes are connected. (visited) ...
Mosbius8's user avatar
3votes
0answers
297views

Kruskal's algorithm in Java - follow-up

The previous and initial iteration at Kruskal's algorithm in Java Now what I did is remove the fields and let the actual Kruskal-routine create the required data structures in the local scope, ...
coderodde's user avatar
6votes
2answers
10kviews

Kruskal's algorithm in Java

I have this Java implementation of Kruskal's algorithm. It solves a tiny problem instance correctly, yet I am not quite sure, whether my implementation is correct. The code as follows: MSTFinder....
coderodde's user avatar
5votes
1answer
8kviews

Prims algorithm implementation

Review this code regarding optimization, cleanup, and best practices. ...
JavaDeveloper's user avatar

close